﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="admin_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Bill Book </title>
    <script src="script/jquery-1.3.2.js" type="text/javascript"></script>
    <script src="script/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
    <link href="stylesheet/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">  
    function PageMethod(fn, paramArray, successFn, errorFn)  
    {  
     var pagePath = window.location.pathname;  
     var paramList = '';  
      if (paramArray.length > 0)  
      {  
       for (var i=0; i<paramArray.length; i+=2)  
       {  
       if (paramList.length > 0) paramList += ',';  
        paramList += '"' + paramArray[i] + '":"' + paramArray[i+1] + '"';  
      }  
     }  
     paramList = '{' + paramList + '}';  
    //Call the page method  
   $.ajax({  
       type: "POST",  
       url: pagePath + "/" + fn,  
        contentType: "application/json; charset=utf-8",  
        data: paramList,  
         dataType: "json",  
         success: successFn,  
         error: errorFn  
     })  
   ;}  
   </script>  
    <script language="javascript" type="application/javascript">

        $(document).ready(function() {
            $("#validatebox").hide();
            $("#errorbox").hide();
            $("#Login").click(function() {
                $("#loginbox").hide();
                $("#errorbox").hide();
                $("#validatebox").show();
                // authenticate the user
                PageMethod('login', ['username', $('#username').val(), 'password', $('#password').val()], OnSucceeded, OnFailed);
            });
        });

        function OnSucceeded(result, context, method) 
        {
            if (result.d == 1) {
                location.href = "dashboard.aspx";
            }
            else {
                $("#validatebox").hide();
                $("#loginbox").show();
                $("#errorbox").show();

            }
        }

        function OnFailed(result, context, method) {
            $("#validatebox").hide();
            $("#loginbox").show();
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
   <div id="adminlogin" >
<div>&nbsp;</div>
<div class="aligncenter"><a href="#"><img src="stylesheet/images/billbooklogo.jpg" alt="Bill Book" /></a></div>
<div>&nbsp;</div>
<div id="loginbox">
<div class="aligncenter"><span class="smallboldblacktext">Username</span></div>
<div class="aligncenter" ><input class="smallblackinput" id="username" type="text" /></div>
<div>&nbsp;</div>
<div class="aligncenter"><span class="smallboldblacktext">Password</span></div>
<div class="aligncenter"><input class="smallblackinput" id="password" type="password" /></div>
<div>&nbsp;</div>
<div class="aligncenter"><input type="button" class="smallblackinput"  id="Login" title="Login to Portal" value="Login" />
</div>
<div>&nbsp;</div>
<div class="aligncenter"><a class="samllbluetext" href="#">Forgot Password</a></div>
</div>
<div id="errorbox" class="aligncenter"><br/><span class="smallredtext"><img src="stylesheet/images/cancel.png" alt=" X " /> Username/Password is Wrong</span><br/></div>
<div id="validatebox" >
<div class="validatingstyle1 aligncenter" ><br/><span class="smallboldblacktext">Validating User Credentials</span><br/><br/></div>
<div class="aligncenter"><br/><img src="stylesheet/images/preloaderline.gif" alt="Loading..." /><br/></div>
</div>
<div>&nbsp;</div>
</div>
    </form>
</body>
</html>
